Skip to content

test: remove sqlite skips for queue-worker tracing (merge after cds spawn fix) - #467

Open
sjvans wants to merge 6 commits into
developfrom
remove-sqlite-queue-worker-skips
Open

test: remove sqlite skips for queue-worker tracing (merge after cds spawn fix)#467
sjvans wants to merge 6 commits into
developfrom
remove-sqlite-queue-worker-skips

Conversation

@sjvans

@sjvans sjvans commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Depends on

  • Base branch feat: trace queue worker transactions + structured span test infrastructure #465 (this is stacked on top of it)
  • CDS queue-spawn fix must be released first and @sap/cds bumped: cap/cds test/queue-spawn-sqlite-extended-tenant — removes the sqlite setTimeout bypass in libx/queue/processing.js (_begin = cds.spawn.bind(cds)) and fixes the actual single-writer deadlock by wrapping ExtendedModels.model4() in cds.tx() inside lib/req/spawn.js.

What

Removes the 5 sqlite skip guards added in #465. Once cds routes the sqlite queue worker through cds.spawn, the cds.spawn - run task root span and its child tx spans appear on sqlite, so these suites verify the full path on sqlite (not just HANA):

  • tracing-scheduled.test.js
  • tracing-outboxed-batch.test.js
  • tracing-messaging-inboxed.test.js
  • tracing-messaging-outboxed-and-inboxed.test.js
  • tracing-messaging-persistent-outbox.test.js

Verified

Locally against a workspace-linked @sap/cds at test/queue-spawn-sqlite-extended-tenant: all 5 suites pass on sqlite.

Note: the AsyncResource.bind approach in cap/cds#6594 does not make these pass — only the test/queue-spawn-sqlite-extended-tenant fix (spawn everywhere + cds.tx-wrapped model4) does. Prefer that fix.

Do not merge until

@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:

⚠️ Warnings:

  • Could not get issue cap-js/telemetry#6594. Status: 404 - UnknownObjectException

Remove SQLite Skip Guards for Queue-Worker Tracing Tests

Test

🧪 Removes the temporary SQLite skip guards from 5 queue-worker tracing test suites that were added in #465 as a workaround for a cds.spawn routing issue on SQLite. Now that the upstream @sap/cds fix routes the SQLite queue worker through cds.spawn (instead of a raw setTimeout bypass), the cds.spawn - run task root span and its child tx spans are correctly emitted on SQLite, allowing these suites to run and verify the full tracing path on SQLite (not just HANA).

Changes

  • test/tracing-scheduled.test.js: Removed the SQLite skip block that prevented queue-worker span assertions from running when db.kind === 'sqlite'.
  • test/tracing-outboxed-batch.test.js: Removed the SQLite skip block for the outboxed batch chunk-size fan-out tracing test.
  • test/tracing-messaging-inboxed.test.js: Removed the unused cds import and the SQLite conditional skip guard.
  • test/tracing-messaging-outboxed-and-inboxed.test.js: Removed the unused cds import and the SQLite conditional skip guard.
  • test/tracing-messaging-persistent-outbox.test.js: Removed the unused cds import and the SQLite conditional skip guard.

Jira Issues (ONLY add this section if JIRA issues are available)

N/A

Related PRs

  • Stacked on top of #465: feat: wrap cds.Service.prototype.tx for queue worker tracing + structured in-memory span test infrastructure.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.29.18

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warnings:

  • Could not get issue cap-js/telemetry#6594. Status: 404 - UnknownObjectException

The changes are straightforward — they remove temporary sqlite skip guards from five test files. Looking at the diff carefully:

  1. In tracing-messaging-inboxed.test.js and tracing-messaging-outboxed-and-inboxed.test.js, the const cds = require('@sap/cds') line is being removed along with the sqlite guard. However, cds is not used anywhere else in those files — so the removal is clean.

  2. In tracing-outboxed-batch.test.js and tracing-scheduled.test.js, cds is still used in the file (for cds.test(...), cds.version, cds.connect.to, etc.), so the removal of the guard is fine and does not leave a dangling require.

  3. In tracing-messaging-persistent-outbox.test.js, same as the messaging files — cds is not directly used in the file body outside what was removed.

The PR description is clear that this is intentionally gated on an upstream CDS fix and the checklist items are unresolved. There are no logic errors, bugs, or maintainability issues introduced by the diff itself — all the removals are consistent and correct.

This is a clean, intentional removal of temporary workaround guards. The diff is correct and all five files are consistent — no issues to flag. The open checklist items in the PR description (#465 merged and @sap/cds bumped) are the only remaining gates before merge, which are appropriately tracked in the PR description itself.

PR Bot Information

Version: 1.29.18

  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.opened
  • Correlation ID: 9e2d0e20-919a-11f1-97de-effae0c5a313
  • File Content Strategy: Full file content

@sjvans
sjvans force-pushed the improve-tracing-and-test-infrastructure branch from 60e48a9 to b281c8f Compare August 6, 2026 13:37
@sjvans
sjvans force-pushed the remove-sqlite-queue-worker-skips branch from 9595503 to 31e0441 Compare August 6, 2026 13:38
@sjvans
sjvans force-pushed the improve-tracing-and-test-infrastructure branch from b281c8f to 9b88203 Compare August 6, 2026 13:41
@sjvans
sjvans force-pushed the remove-sqlite-queue-worker-skips branch 3 times, most recently from 81c9cd9 to 5eb33aa Compare August 6, 2026 14:04
@sjvans
sjvans force-pushed the improve-tracing-and-test-infrastructure branch from 89d1e87 to 29710d5 Compare August 7, 2026 08:05
@sjvans
sjvans force-pushed the remove-sqlite-queue-worker-skips branch from 5eb33aa to 5fe19e4 Compare August 7, 2026 08:05
@sjvans
sjvans force-pushed the improve-tracing-and-test-infrastructure branch from 29710d5 to 3983e27 Compare August 7, 2026 08:55
@sjvans
sjvans force-pushed the remove-sqlite-queue-worker-skips branch from 5fe19e4 to 179982c Compare August 7, 2026 08:55
sjvans added 4 commits August 7, 2026 15:47
… log-regex tests with structured in-memory spans

Queue worker tracing:
- Wraps cds.Service.prototype.tx() so that the queue worker's two-transaction
  structure (SELECT+UPDATE lock tx, then handle+DELETE dispatch tx) appears as
  child spans under their trace root instead of each top-level CAP call inside
  them becoming an orphan root.
- Guard: skips when this.context instanceof cds.EventContext so $batch sub-requests
  are not affected, and skips the bare {} context from processInboundMsg so
  file-based messaging consumer delivery gets a messaging - tx root span.
- SQLite note: CDS uses a raw setTimeout bypass for sqlite queue workers (to avoid
  deadlocks) so cds.spawn is not called, and spawn-root tracing is not available on
  sqlite. Affected tests are skipped on sqlite and verified on HANA in CI.

Test infrastructure (from PR #450):
- MyInMemorySpanExporter: structured in-memory span store replacing fragile
  cds.test.log() regex matching. groupedByTrace() / rootSpans() helpers let
  tests assert on span trees directly.
- tracing-in-memory profile in .cdsrc.json; tracing-attributes profile preserved.
- tracing.test.js, tracing-attributes.test.js, tracing-mt.test.js,
  tracing-messaging*.js rewritten to use structured span assertions.
- New test files: tracing-scheduled, tracing-outboxed-batch,
  tracing-messaging-inboxed, tracing-messaging-outboxed-and-inboxed,
  tracing-messaging-persistent-outbox, console-span-exporter (unit test).
- tracing-messaging.js: configurable waitMs (default 2500ms, 4000ms for
  inbox/persistent-outbox scenarios); afterAll wait bumped to 2s.
- admin-service: test_outboxed_send / test_outboxed_send_batch / test_scheduled
  actions added for the new test scenarios.
The queue-worker tracing tests (scheduled, outboxed-batch, and the inboxed/
outboxed-and-inboxed/persistent-outbox messaging cases) assert on the
'cds.spawn - run task' root span and its child tx spans. That root only
appears when @sap/cds routes the sqlite queue worker through cds.spawn.
Published cds uses a raw setTimeout bypass on sqlite (to avoid a single-writer
deadlock), so those spans never appear there.

Skip these suites on sqlite until the cds fix lands (cap/cds branch
test/queue-spawn-sqlite-extended-tenant, which removes the bypass by fixing
the actual deadlock root cause). A follow-up PR removes these skips once the
required cds version is released. HANA CI already exercises the full path.
…quire, tighten mt assertion

- Number(cds.version.split('.')[0]) < 9 instead of relying on string coercion
  (tracing-outboxed-batch, tracing-scheduled)
- hoist single hrTimeToNanoseconds require, drop the double require in the sort
  comparator (tracing-outboxed-batch)
- multitenancy: assert exactly one AdminService READ span (filter + length 1)
  instead of find, guarding against residue leaking past reset (tracing-mt)

Skipped bot findings: byParent[undefined] (field is unused by any test);
tx double-wrap guard (same pattern as existing emit/handle wraps, plugin
loads once per process).
@sjvans
sjvans force-pushed the improve-tracing-and-test-infrastructure branch from 3983e27 to 74d924a Compare August 7, 2026 13:51
@sjvans
sjvans force-pushed the remove-sqlite-queue-worker-skips branch from 179982c to 91c38f7 Compare August 7, 2026 13:52
sjvans added 2 commits August 7, 2026 16:02
Messaging is outboxed by default, so `outboxed: true, inboxed: true` exercises
the exact same code path and asserts the identical span shape as the `inboxed`
test. Remove the duplicate test + its unused .cdsrc profile.
Removes the sqlite skip guards added while the cds queue-spawn fix was pending.
With cds routing the sqlite queue worker through cds.spawn (cap/cds branch
test/queue-spawn-sqlite-extended-tenant: removes the setTimeout bypass and fixes
the underlying deadlock by wrapping ExtendedModels.model4() in cds.tx()), the
'cds.spawn - run task' root span and its child tx spans now appear on sqlite too.

Merge only after that cds fix is released and the @sap/cds dependency is bumped.
@sjvans
sjvans force-pushed the remove-sqlite-queue-worker-skips branch from 91c38f7 to d1812a1 Compare August 7, 2026 14:03
sjvans added a commit that referenced this pull request Aug 10, 2026
…ucture (#465)

## Added

Wraps `cds.Service.prototype.tx()` so the queue worker's two-transaction
structure (tx1: SELECT+UPDATE lock, tx2: handle+DELETE dispatch) appears
as coherent `<service> - tx` spans under the `cds.spawn - run task`
root, instead of each top-level CAP call becoming an orphan root.
Guarded so `$batch` sub-requests (active `EventContext`) are unaffected;
file-based messaging consumer delivery (bare `{}` context) still gets a
root span.

## Test infrastructure

Replaces fragile `cds.test.log()` regex assertions with a structured
in-memory span exporter (`MyInMemorySpanExporter`) and
`groupedByTrace()` / `rootSpans()` helpers. Rewrites the existing
tracing suites and adds coverage for scheduled tasks, outboxed batch
fan-out, and inbox/outbox messaging combinations.

## SQLite note

Queue-worker suites skip on sqlite (published `@sap/cds` uses a
`setTimeout` bypass, not `cds.spawn`) — verified on HANA in CI.
Follow-up #467 removes the skips once the cds queue-spawn fix ships.

Changelog updated. Targets `develop`.
Base automatically changed from improve-tracing-and-test-infrastructure to develop August 10, 2026 08:38
@sjvans

sjvans commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Part of the broader skip-elimination tracked in #477 (item 1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant